Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
Trigger procedure headers
A trigger procedure must be an external 4GL procedure. That is, it must be a procedure file of its own, not an internal procedure within some larger procedure file. It can contain just about any 4GL code. It is identified by a special header statement at the top of the procedure file.
CREATE, DELETE, and FIND headers
The header statement for a
CREATE,DELETE, orFINDprocedure has this syntax:
This statement effectively defines a buffer automatically with the same name as the table, scoped to the trigger procedure.
WRITE header
The header statement for a
WRITEtrigger has this syntax:
When executing a
WRITEtrigger, Progress makes two record buffers available to the trigger procedure. TheNEWbuffer contains the modified record that is being validated. TheOLDbuffer contains the most recent version of the record before the latest set of changes was made. This is the template record that holds initial values for a table if it is a newly-created record, the record from the database if the record has not been validated or the most recently validated record if it has been validated. The default for the new buffer is the automatically-created buffer named for the table itself, which makes theNEWphrase optional. If you wish to compare the new buffer to the old, you must use theOLDphrase to give the old one a name. TheBUFFERkeyword is just optional syntactic filler.You can make changes to the
NEWbuffer, but theOLDbuffer is read-only.You can determine whether the record being written is newly created using the Progress
NEWfunction, which returns true if Progress has not written the record to the database before, and false otherwise:
For example:
ASSIGN header
The header statement for an
ASSIGNtrigger has this syntax:
If you use the
OFform, the expressiontable.fieldidentifies the field, but you can in fact refer to any field in the record where the field has been changed.If you need to compare the field value before and after it was changed, you must use the
NEWandOLDphrases to give those versions of the field names. If you do this, you cannot refer to the rest of the record buffer. You can change theNEWfield, and this changes the field value in the record, but changing theOLDfield value has no effect. TheVALUEkeyword here is just optional syntactic filler.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |